﻿using System.Text.RegularExpressions;
using DTM.Model;
using FluentValidation;

namespace DTM.Domain.Players
{
	/// <summary>
	/// Class declare game player validator.
	/// </summary>
	public class PlayerValidator : AbstractValidator<IPlayer>, IValidator<IPlayer>
	{
		public PlayerValidator()
		{
			RuleFor(player => player.Name).NotEmpty();
			RuleFor(player => player.Name).Length(1, 50);
			RuleFor(player => player.Surname).NotEmpty();
			RuleFor(player => player.Surname).Length(1, 50);
			RuleFor(player => player.Email).NotEmpty();
			RuleFor(player => player.Email).Length(1, 100);
			RuleFor(player => player.Email).Matches(new Regex(@"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$"));
		}
	}
}
